
<div class="row-fluid sortable ui-sortable">
    <div class="box span12">
        <form action="" method="post">
        <div class="box-header well">
            <h2>Page</h2>
            <a href="<?= $this->url('admin/child', array('controller'=>'page','action' => 'add')) ?>" class="btn btn-primary pull-right">New page</a>
        </div>
        <div class="box-content">

        <table class="table table-condensed">
        <thead>
        <style>
            table tr{
                vertical-align: middle !important;
            }
            table thead tr th{
                text-align: center !important;
            }
        </style>
        <tr align=""center">
            <th><input type="checkbox" id="checkall" style="opacity: 1!important;"></th>
            <th>Title</th>
            <th>Date registered</th>
            <th>Parent id</th>
            <th>Status</th>
            <th >Actions</th>
        </tr>
        </thead>
        <tbody>
        <?php
        if(count($page) >0){

            foreach($page as $key=>$item){
                $arrPage[] = $item;
            }

            function draw($topic_cat, $parent,$prefix = '' )
            {
                foreach ($topic_cat as $value) {

                    if ($value->page_parent == $parent) {
                        $id = $value->id;
                     ?>
                        <tr>
                            <td class="center"><input class="checkbox" type="checkbox" name="id[]" value="<?=$value->id?>" style="opacity: 1!important;"></td>
                            <td><?=$prefix.' '.$value->title ?></td>
                            <td class="center"><?php echo date("d-m-Y",$value->page_date)?></td>
                            <td class="center"><?php echo $value->page_parent?></td>
                            <td class="center">
                                <span class="label label-success"><?php echo $value->status ?></span>
                            </td>
                            <td class="center">
                                <a class="btn btn-info" href="/admin_abc_xyz/page/edit/<?=$value->id?>">
                                    <i class="icon-edit icon-white"></i>
                                    Edit
                                </a>
                                <a class="btn btn-danger" href="/admin_abc_xyz/page/delete/<?=$value->id?>">
                                    <i class="icon-trash icon-white"></i>
                                    Delete
                                </a>
                            </td>
                        </tr> <?php

                        draw($topic_cat,$id,$prefix.'--');

                    }

                }


            }

            draw($arrPage,0);
        }else{ ?>
           <tr> <td colspan="6">There is no data</td>   </tr>
        <?php }

        ?>


        </tbody>
        </table>
        </div>
        </form>
    </div>
</div>
<script>
    $(document).ready(function(){
        $('#checkall').click(function (event) {  //on click
            if (this.checked) { // check select status
                $('.checkbox').each(function () { //loop through each checkbox
                    this.checked = true;  //select all checkboxes with class "checkbox1"
                });
            } else {
                $('.checkbox').each(function () { //loop through each checkbox
                    this.checked = false; //deselect all checkboxes with class "checkbox1"
                });
            }
        });
    })
</script>
